<html>
    <head>
        <title>
            PAGE_DEMO
        </title>
        <script type="text/javascript">

        <!--

            var compute = function(){
                var records = getRecords();
                console.log("start");
                sortRecords(records)
                var salarySummary = calculateTax(records);
                calculateSalary(salarySummary);
                console.log("end");
            };

            var sortRecords = function(records){
                var list = [];
                for (var p in records)
                    list.push(records[p]);
                list.sort(function(a,b){return a.salary-b.salary;});
            };

            var calculateTax = function(records){
                result = [];
                for (var p in records){
                    var record = records[p];
                    var summary = {};
                    summary.tax = false;
                    try{
                       record.lastName.length;
                       summary.salary = record.salary;
                       if (record.age < 50 || record.salary>100000){
                           summary.tax = true;}
                    }catch(exc){
                       //ignore
                    }
                    result.push(summary);
                }
                return result;
            };

            var calculateSalary = function(result){

                for (var i=0; i<result.length; i++){
                    var finalSalary = {};
                    var record = result[i];
                    var baz = record.salary;
                    if (record.tax){
                        finalSalary.value = record.salary;
                    }else{
                        finalSalary.value = baz*2;
                    };
                    if  (finalSalary.value > 200000){
                        console.log("Salary is higher than limit : " + finalSalary.value + " > 200000");
                    }
                }
            };

            var getRecords = function(){
                return {
                A:{id:33, name:"John", lastName:"Barton", company:"IBM", age:"54", salary:"100000"},
                B:{id:33, name:"John", lastName:"Barton", company:"IBM", age:"44", salary:"100000"}
                };
            };

        -->
        </script>

    </head>

    <body id="myBody" onclick="compute()">
    <p>
    </P>
    <p id="reproducer">
    </P>
    <p id>

    </p>
    </body>

</html>